package com.sanrenzu.everybodytv.ui.mine.recommend;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sanrenzu.everybodytv.R;
import com.sanrenzu.everybodytv.widget.GlideRoundTransform;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class LogOutActivity extends AppCompatActivity {

    @BindView(R.id.imageView_logOut_back)
    ImageView imageViewLogOutBack;
    @BindView(R.id.imageView_logOut_face)
    ImageView imageViewLogOutFace;
    @BindView(R.id.textView_logOut_Name)
    TextView textViewLogOutName;
    @BindView(R.id.textView_logOut_emiale)
    TextView textViewLogOutEmiale;
    @BindView(R.id.textView_logOut_phone)
    TextView textViewLogOutPhone;
    @BindView(R.id.button_logOut_Out)
    Button buttonLogOutOut;
    //声明黄油刀
    private Unbinder bind;
    private String url;
    private String name;
    //声明上下文
    private Context mContext = this;
    private static final String LOHGIN = "AA";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_log_out);
        bind = ButterKnife.bind(this);
        initData();
        initView();
        initOther();
    }

    private void initOther() {
        buttonLogOutOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences share = mContext.getSharedPreferences(LOHGIN, mContext.MODE_PRIVATE);
                SharedPreferences.Editor editor = share.edit();
                editor.clear();
                editor.commit();
                finish();
            }
        });
    }

    private void initView() {
        Glide.with(mContext).load(url)
                .transform(new GlideRoundTransform(mContext, 90))
                .into(imageViewLogOutFace);
        textViewLogOutName.setText(name);
    }

    private void initData() {
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        url = bundle.getString("URL");
        name = bundle.getString("NAME");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        bind.unbind();
    }
}
